package com.example.administrator.hqq.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

/**
 * @name: HQQ
 * @describe:
 * @author: 康海涛 QQ2541849981
 * @time: 2019/1/25 12:29
 * @remark:
 */
public class AlertDialogUtil {
    private AlertDialogClick.ConfirmClick confirmClick;
    public static void showTitleAlertDialog(Context context, String title, final AlertDialogClick.ConfirmClick confirmClick){
        AlertDialog.Builder normalDialog = new AlertDialog.Builder(context);
        normalDialog.setTitle(title);
        normalDialog.setPositiveButton("确定",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (confirmClick!=null)
                        {
                            confirmClick.confirm();
                        }
                    }
                });
        normalDialog.setNegativeButton("关闭",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //...To-do
                    }
                });
        // 显示
        normalDialog.show();
    }

    public static void showTitleAlertDialog(Context context, String title,String confirm,String cancel, final AlertDialogClick.ConfirmClick confirmClick){
        AlertDialog.Builder normalDialog = new AlertDialog.Builder(context);
        normalDialog.setTitle(title);
        normalDialog.setPositiveButton(confirm,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (confirmClick!=null)
                        {
                            confirmClick.confirm();
                        }
                    }
                });
        normalDialog.setNegativeButton(cancel,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //...To-do
                    }
                });
        // 显示
        normalDialog.show();
    }
    public static void showTitleAlertDialog(Context context, String title,String content, final AlertDialogClick.ConfirmClick confirmClick){
        AlertDialog.Builder normalDialog = new AlertDialog.Builder(context);
        normalDialog.setTitle(title);
        normalDialog.setMessage(content);
        normalDialog.setPositiveButton("确定",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (confirmClick!=null)
                        {
                            confirmClick.confirm();
                        }
                    }
                });
        normalDialog.setNegativeButton("关闭",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //...To-do
                    }
                });
        // 显示
        normalDialog.show();
    }
    public interface AlertDialogClick{
        interface ConfirmClick{
            void confirm();
        }
    }
}

